﻿' <summary>
' BeeWit IDE Entorno de desarrollo Visual para php.
' BeeWitPHP IDE es el único entorno de desarrollo para PHP 
' de tipo WYSIWYG (What You See Is What You Get). 
' ¡Ahora si!, aproveche la potencia del lenguaje PHP 
' y desarrolle más rápidamente gracias a la programación 
' intuitiva de BeeWit.
' Copyright © 2010 Dewins Murillo Garcia 
' EMAIL: dewinsmg@gmail.com
' EMAIL: dewins@beewitsoft.com
' Este Programa es Software Libre: usted puede redistribuirlo 
' y/o modificarlo bajo los términos de la Licencia Publica General 
' GNU como es publicada por la Fundacion de Software Libre; 
' en la 3ra versión de la licencia.
' Este programa es distribuido con la esperanza de que sea útil, 
' pero SIN GARANTÍA ALGUNA; sin siquiera la garantía implícita 
' de VALOR COMERCIAL o FORMADO PARA UN PROPÓSITO EN PARTICULAR. 
' Vea la Licencia Publica General GNU para mas detalles.
' Usted debe haber recibido una copia de la Licencia Publica General 
' GNU junto con este programa. Si no, vaya a http://www.beewitsoft.com
' o en http://code.google.com/p/ajax-beewit-php-ide/
' </summary>
' <remarks></remarks>

Imports mshtml
Imports WeifenLuo.WinFormsUI
Imports WeifenLuo.WinFormsUI.Docking
Imports ICSharpCode.TextEditor
Imports ICSharpCode.TextEditor.Document
Imports xdc.XDebug

Public Class ctlEditor

#Region "Declarations"
    Public Path As String
    Public WithEvents HTML As New clsHTML
    Public WithEvents _EditorControlCode As New clsEditorCode
    Public WithEvents _EditorControlHTML As New clsEditorCode
    Public Node As clsNode
    Protected WithEvents cboObjects As New Talex.Controls.ImageCombo.ImageCombo
    Protected WithEvents cboMethods As New Talex.Controls.ImageCombo.ImageCombo
    Private TextLoaded As Boolean = False

#End Region



    Public Sub Save()
        If btnDesign.Visible = True Then
            If btnDesign.Enabled = False Then
                _EditorControlHTML.Document.Text = DesignToHTML(Me.webDesign.Document.Body.InnerHtml)
            End If
        End If
        Me.Node.ContentView = Me._EditorControlHTML.Document.Text
        Me.Node.ContentCode = Me._EditorControlCode.Document.Text
        If Me.Node.TypeCode = clsNode.enumTypeCode.isCONTROL Then
            Project_Interfaz.SetContentFile(Me.Node.Path, Me.Node.ContentCode)
            Project_Interfaz.SetContentFile(Me.Node.Path & ".view", Me.Node.ContentView)
        Else
            If Me.Node.TypeCode = clsNode.enumTypeCode.isCLASS Or Me.Node.TypeCode = clsNode.enumTypeCode.isPHP Or Me.Node.TypeCode = clsNode.enumTypeCode.isOTHER Or Me.Node.TypeCode = clsNode.enumTypeCode.isTXT Or Me.Node.TypeCode = clsNode.enumTypeCode.isJS Then
                Project_Interfaz.SetContentFile(Me.Node.Path, Me.Node.ContentCode)
            Else
                If Me.Node.TypeCode = clsNode.enumTypeCode.isHTML Then
                    Project_Interfaz.SetContentFile(Me.Node.Path, Me.Node.ContentView)
                Else
                    Project_Interfaz.SetContentFile(Me.Node.Path, Me.Node.ContentCode)
                End If
            End If
        End If
        If Not General.Control_Main.ActualEditor Is Nothing Then
            General.Control_Main.tabContainer.ItemTitles.Item(General.Control_Main.ActualEditor) = General.Control_Main.tabContainer.ItemTitles.Item(General.Control_Main.ActualEditor).Replace(" *", "")
        End If
    End Sub

    Public Sub ShowEditor()
        If Node.TypeCode = clsNode.enumTypeCode.isCONTROL Then 'enabled web designer, html code and php code
            btnDesign.Visible = True
            btnHTML.Visible = True
            btnCode.Visible = True
            btnDesign.Enabled = False
            btnHTML.Enabled = True
            btnCode.Enabled = True
            ShowCode()
            ShowHTML()
            ShowDesign()
        Else
            If Node.TypeCode = clsNode.enumTypeCode.isHTML Then 'enabled web designer and html code
                btnDesign.Visible = True
                btnHTML.Visible = True
                btnCode.Visible = False
                btnDesign.Enabled = False
                btnHTML.Enabled = True
                btnCode.Enabled = True
                ShowHTML()
                ShowDesign()
            Else 'enabled only php code
                btnDesign.Visible = False
                btnHTML.Visible = False
                btnCode.Visible = True
                btnDesign.Enabled = True
                btnHTML.Enabled = True
                btnCode.Enabled = False
                ShowCode()
            End If
        End If
        FocusOnActivity()
    End Sub

    Private Sub ShowDesign()
        Me.webDesign.Dock = DockStyle.Fill
        Try
            Me.webDesign.Navigate("about:blank")
            Application.DoEvents()
            Dim ArchivoTmp As String = CreateHtmlView(Node.ContentView, Node.Text, "")
            Me.webDesign.Navigate(ArchivoTmp)
            If Node.TypeCode = clsNode.enumTypeCode.isHTML Then
            Else
                Me.webDesign.ActiveXInstance.Document.DesignMode = "On"
                Me.webDesign.IsWebBrowserContextMenuEnabled = False
            End If
            HTML.HTML = webDesign.Document
            HTML.TSTags = Me.TSTags
            _EditorControlCode.AutoListIcons = General.Object_Icons.bmpImageList

        Catch ex As Exception
            MsgBox(Err.Description, MsgBoxStyle.Critical, "Editor")
        End Try
    End Sub

    Private Sub ShowHTML()
        _EditorControlHTML.Node = Me.Node
        _EditorControlHTML.ContentType = clsEditorCode.TypeContent.isVIEW
        _EditorControlHTML.Dock = DockStyle.Fill
        _EditorControlHTML.Document.Parser.Init(Application.StartupPath & "\resources\xml\syntax_html.syn")
        _EditorControlHTML.Document.Text = Node.ContentView
        Me.PnHTML.Controls.Add(_EditorControlHTML)
    End Sub

    Private Sub ShowCode()
        Dim SYNTAX As String = "php"
        If Node.Extention.ToUpper = "JS" Then
            SYNTAX = "javascript"
        End If
        If Node.Extention.ToUpper = "CSS" Then
            SYNTAX = "css"
        End If
        If Node.Extention.ToUpper = "TXT" Then
            SYNTAX = "text"
        End If
        _EditorControlCode.Node = Me.Node
        _EditorControlCode.ContentType = clsEditorCode.TypeContent.isCODE
        _EditorControlCode.Dock = DockStyle.Fill
        _EditorControlCode.Document.Parser.Init(Application.StartupPath & "\resources\xml\syntax_" & SYNTAX & ".syn")
        _EditorControlCode.Document.Text = Node.ContentCode
        Me.pnCode.Controls.Add(_EditorControlCode)
    End Sub

    Private Sub FocusOnActivity()
        Me.PnDesign.Visible = False
        Me.PnHTML.Visible = False
        Me.PnCodeBase.Visible = False
        If Not Me.btnDesign.Enabled Then
            Me.PnDesign.Dock = DockStyle.Fill
            Me.PnDesign.Visible = True
        End If
        If Not Me.btnHTML.Enabled Then
            Me.PnHTML.Dock = DockStyle.Fill
            Me.PnHTML.Visible = True
        End If
        If Not Me.btnCode.Enabled Then
            Me.PnCodeBase.Dock = DockStyle.Fill
            Me.PnCodeBase.Visible = True
            Me.pnCode.Visible = True
        End If
    End Sub

    Private Sub btnDesign_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDesign.Click
        If btnHTML.Enabled = False Then
            Node.ContentView = _EditorControlHTML.Document.Text
            Dim TmpFile As String = CreateHtmlView(Node.ContentView, Node.Text, "", "") 'Node.ContentView
            Me.webDesign.Refresh()
            'Me.webDesign.Document.Body.InnerHtml = _EditorControlHTML.Document.Text
        End If
        btnDesign.Enabled = False
        btnHTML.Enabled = True
        btnCode.Enabled = True
        FocusOnActivity()
        If General.Control_Main.tabContainer.ItemTitles.Item(General.Control_Main.ActualEditor).IndexOf("*") > 0 Then
        Else
            TextLoaded = False
        End If
        BeeWitFocused = True
        General.Control_Properties.Enabled = True
        General.Control_Eventos.Enabled = True
        General.Control_Controls.Enabled = True
    End Sub

    Private Sub btnHTML_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnHTML.Click
        If btnDesign.Enabled = False Then
            _EditorControlHTML.Document.Text = DesignToHTML(Me.webDesign.Document.Body.InnerHtml)
        End If
        btnDesign.Enabled = True
        btnHTML.Enabled = False
        btnCode.Enabled = True
        FocusOnActivity()
        TextLoaded = True
    End Sub

    Private Sub btnCode_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCode.Click
        ExecuteBtnCodeClick()
        TextLoaded = True
    End Sub

    Public Sub FlushHTML()
        _EditorControlHTML.Document.Text = DesignToHTML(Me.webDesign.Document.Body.InnerHtml)
        Dim ArchivoTmp As String = CreateHtmlView(Me.webDesign.Document.Body.InnerHtml, Node.Text, "")
    End Sub

    Public Sub ExecuteBtnCodeClick()
        If btnHTML.Enabled = False Then
            Node.ContentView = _EditorControlHTML.Document.Text
            Dim ArchivoTmp As String = CreateHtmlView(Node.ContentView, Node.Text, "")
            Me.webDesign.Refresh()
        End If
        If btnDesign.Enabled = False Then
            _EditorControlHTML.Document.Text = DesignToHTML(Me.webDesign.Document.Body.InnerHtml)
        End If
        btnDesign.Enabled = True
        btnHTML.Enabled = True
        btnCode.Enabled = False
        FocusOnActivity()
    End Sub

    Private Function GetFunctionClose(ByVal Content As String, ByVal PosStart As Long) As Long
        Dim CountOpen As Long = 0
        GetFunctionClose = PosStart
        For i = PosStart To Content.Length - 1
            GetFunctionClose = i
            If Mid(Content, i, 1) = "{" Then
                CountOpen += 1
            End If
            If Mid(Content, i, 1) = "}" Then
                CountOpen -= 1
                If CountOpen = 0 Then
                    Exit Function
                End If
            End If
        Next
    End Function

    'Public Function CreateHtmlView(ByVal Content As String, ByVal Id As String, ByVal Iframe As String, Optional ByVal ClassCode As String = "") As String
    Public Function CreateHtmlView(ByVal Content As String, ByVal Id As String, ByVal ContentParent As String, Optional ByVal ClassCode As String = "") As String
        Dim ClassName As String = ClassCode.Substring((ClassCode.LastIndexOf("\")) + 1).Replace(".cjx", "")
        Dim NodeFound As clsNode = Control_Explorer.SearchClass(ClassName)
        If Not NodeFound Is Nothing Then
            ContentParent = Content
            Content = NodeFound.ContentView
        Else
            If ClassName <> "" And NodeFound Is Nothing Then
                MsgBox("Class [" & ClassName & "] not found ")
                Return ""
            End If
        End If
        Content = Object_Expression.ReplaceControlsCJXToIframe(Content)
        Content = Object_Expression.ReplaceAttributeClassCode(Content)
        Dim dtChildControls As DataTable = Object_Expression.GetUserControlsAsIframe(Content)
        Dim dtProperties As DataTable = Object_Expression.GetHTMLProperties(ContentParent)
        If Not NodeFound Is Nothing Then
            Dim ContentCode As String = NodeFound.ContentCode
            For Each rowControl As DataRow In dtProperties.Rows
                Dim DesignAttribute As String = ""
                Dim PosStart As Long = ContentCode.IndexOf("set_" & rowControl("propertyname") & "(")
                If PosStart > 0 Then
                    Dim PosEnd As Long = GetFunctionClose(ContentCode, PosStart)
                    If PosEnd > PosStart Then
                        Dim FunctionCode As String = ContentCode.Substring(PosStart, PosEnd - PosStart)
                        Dim dtDesignProperties As DataTable = Object_Expression.GetDesignAttibutes(FunctionCode)
                        For Each rowControlDesign As DataRow In dtDesignProperties.Rows
                            Dim vDesign() As String = rowControlDesign("designattributes").ToString.Split("|")
                            Dim vComplexAttibute() As String = vDesign(1).ToString.Split("@")
                            If dtChildControls.Rows.Count > 0 Then
                                If vComplexAttibute.Length > 1 Then
                                    Content = Replace(Content, "id=" & Id, "id=" & Id & " " & vComplexAttibute(0) & "='" & vComplexAttibute(1) & ":" & rowControl("propertyvalue") & "'")
                                Else
                                    Content = Replace(Content, "id=" & Id, "id=" & Id & " " & vDesign(1) & "='" & rowControl("propertyvalue") & "'")
                                End If
                            Else
                                If vComplexAttibute.Length > 1 Then
                                    Content = Replace(Content, "id=" & vDesign(0), "id=" & vDesign(0) & " " & vComplexAttibute(0) & "='" & vComplexAttibute(1) & ":" & rowControl("propertyvalue") & "'")
                                Else
                                    Content = Replace(Content, "id=" & vDesign(0), "id=" & vDesign(0) & " " & vDesign(1) & "='" & rowControl("propertyvalue") & "'")
                                End If
                            End If
                        Next
                    End If
                End If
            Next
        End If

        If Id.IndexOf(".cjx") < 0 Then
            Id = Id & ".cjx"
        End If
        Object_LocalFiles.CreateFile(TempDir & "" & Id & ".html", False)
        If String.IsNullOrEmpty(ClassCode) Then
            Object_LocalFiles.SetContentFile(TempDir & "" & Id & ".html", "<body style='margin: 0px;'>" & General.StyleDezingTable & Content & "")
        Else
            Object_LocalFiles.SetContentFile(TempDir & "" & Id & ".html", "<body style='margin: 0px;'><div style=""width:100%; height:100%; background-color:" & General.Settings.GetTagValue("editing_controls_color") & "; opacity:" & General.Settings.GetTagValue("editing_controls_opacity") & "; filter:alpha(opacity=" & General.Settings.GetTagValue("editing_controls_opacity_alpha") & ");zoom:1; position:absolute; z-index: 9999"">" & General.StyleDezingTable & Content & "</div>")
        End If
        Dim dt As DataTable = Object_Expression.GetUserControlsAsIframe(Content)
        For Each rowControl As DataRow In dt.Rows
            'CreateHtmlView(Project_Interfaz.GetContentFile(Project_Path & rowControl("class_code") & ".view"), rowControl("id") & ".cjx", rowControl("iframe"), rowControl("class_code"))
            CreateHtmlView(rowControl("iframe"), rowControl("id"), Content, rowControl("class_code"))
        Next
        Return TempDir & "" & Id & ".html"
    End Function

    Private Function DesignToHTML(ByVal Content As String) As String
        Content = Object_Expression.ReplaceControlsIframeToCJX(Content)
        Content = Object_Expression.DeleteSrcInCjx(Content)
        Content = Object_Expression.DeleteFrameborderInCjx(Content)
        Content = Object_Expression.DeleteScrollingInCjx(Content)
        Content = Object_Expression.DeleteNoResizeInCjx(Content)
        Content = Object_Expression.DeleteBorderInCjx(Content)
        Content = Object_Expression.DeleteFrameSpacingInCjx(Content)
        Content = Replace(Content, General.StyleDezingTable, "", , , CompareMethod.Text)
        'RECOVERY CONTROL VARS WITHOUT INSTANCE

        Return Content
    End Function

    Public Function AddControl(ByVal ClassName As String, Optional ByVal AddHtmlElement As Boolean = True) As String
        Dim NodeControlAdded As clsNode = Control_Explorer.SearchClass(ClassName)
        Dim ControlId As String = ClassName
        Dim iName As Long = 1
        Dim ContentView As String = _EditorControlHTML.Document.Text
        
        If AddHtmlElement Then
            Do
                ControlId = ClassName & "_" & iName
                If Me.Node.ContentView.IndexOf(ControlId) < 0 Then
                    Exit Do
                End If
                iName += 1
            Loop
            AddControl = ControlId
            HTML.HTML.ExecCommand("InsertIFrame", False, ControlId)
            Dim Element As HtmlElement = HTML.HTML.ActiveElement.Document.GetElementById(ControlId)
            If Not Element Is Nothing Then
                Dim ClassCode As String = NodeControlAdded.FullPath.Replace(General.Project_Name, "")
                Element.SetAttribute("class_code", ClassCode)
                Element.SetAttribute("frameborder", "0")
                Element.SetAttribute("framespacing", "0")
                Element.SetAttribute("scrolling", "no")
                Element.SetAttribute("scroll", "no")
                Element.SetAttribute("noresize", "yes")
                Element.SetAttribute("border", "0")
                Element.SetAttribute("name", ControlId)
                Element.SetAttribute("height", General.Settings.GetTagValue("default_iframe_height"))
                Dim tmpView As String = CreateHtmlView(NodeControlAdded.ContentView, ControlId, "")
                Element.SetAttribute("src", tmpView)
                Me.Node.ContentView = Me.webDesign.Document.Body.InnerHtml
                Dim ArchivoTmp As String = CreateHtmlView(Node.ContentView, Node.Text, "")
                Me.webDesign.Refresh()
                FlushHTML()
                Element = HTML.HTML.ActiveElement.Document.GetElementById(ControlId)
                Element.ScrollIntoView(True)
            End If
        Else
            Do
                ControlId = ClassName & "_" & iName
                If Me.Node.ContentCode.IndexOf(ControlId) < 0 Then
                    Exit Do
                End If
                iName += 1
            Loop
            AddControl = ControlId
        End If
        _EditorControlHTML.Document.Text = DesignToHTML(Me.webDesign.Document.Body.InnerHtml)
        Me.Node.ContentView = _EditorControlHTML.Document.Text
        'instance the object
        CreateInstance(ControlId, ClassName)
        TextLoaded = True
    End Function

    Private Sub CreateInstance(ByVal ControlId As String, ByVal ClassName As String)
        If Node.ContentCode.IndexOf(ControlId) <= 0 Then
            Me.Node.ContentCode = Me.Node.ContentCode.Replace("parent::__construct($control_parent);", "")
            Me.Node.ContentCode = Object_Expression.ReplaceBeginClass(Me.Node.ContentCode, " protected $" & ControlId & ";")
            _EditorControlCode.Document.Text = Me.Node.ContentCode
            Me.Node.ContentCode = Object_Expression.ReplaceConstructor(Me.Node.ContentCode, "      parent::__construct($control_parent);" & vbCrLf & "      $this->" & ControlId & " = new " & ClassName & "($this);")
            _EditorControlCode.Document.Text = Me.Node.ContentCode
        End If
    End Sub

    Private Sub webDesign_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles webDesign.DocumentCompleted

    End Sub

    Public Sub New()

        ' Llamada necesaria para el Diseñador de Windows Forms.
        InitializeComponent()
        Me.HTML.Browser = Me.webDesign
        ' Agregue cualquier inicialización después de la llamada a InitializeComponent().

    End Sub

    Private Sub ctlEditor_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        cboObjects.Dock = DockStyle.Fill
        cboMethods.Dock = DockStyle.Fill

        cboObjects.ImageList = _EditorControlCode.AutoListIcons
        cboMethods.ImageList = _EditorControlCode.AutoListIcons

        Me.PnObjects.Controls.Add(cboObjects)
        Me.PnMethods.Controls.Add(cboMethods)

        cboObjects.TabStop = False
        cboMethods.TabStop = False

        _EditorControlCode.cboObjects = Me.cboObjects
        _EditorControlCode.cboMethods = Me.cboMethods
    End Sub

    Private Sub ctlEditor_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDoubleClick
        Dim j As Long = 0
    End Sub


    Private Sub cboObjects_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboObjects.GotFocus
        _EditorControlCode.FillComboObjects()
    End Sub

    Public Sub ExecuteTagCommand(ByVal Command As String, ByVal Value As String)
        If Me.btnDesign.Visible = True Then 'see if enable dezign properties, event a controls
            If Me.btnDesign.Enabled = False Then 'design selected
                If Command = "Paste" Then
                    Dim HtmlDataToPaste As String = HtmlDataCopied
                    Dim htmlDocument As IHTMLDocument2 = webDesign.Document.DomDocument
                    Dim currentSelection As IHTMLSelectionObject = htmlDocument.selection
                    If Not currentSelection Is Nothing Then
                        Dim range As IHTMLTxtRange = currentSelection.createRange()
                        If Not range Is Nothing Then
                            If Not HtmlDataToPaste Is Nothing Then
                                Dim dt As DataTable = Object_Expression.GetUserControlsAsIframe(HtmlDataToPaste)
                                For Each rowControl As DataRow In dt.Rows
                                    Dim ClassName As String = rowControl("class_code").Substring((rowControl("class_code").LastIndexOf("\")) + 1).Replace(".cjx", "")
                                    Dim NewNameControl As String = General.Control_Main.ActualEditor.AddControl(ClassName, False)
                                    HtmlDataToPaste = HtmlDataToPaste.Replace(rowControl("id"), NewNameControl)
                                    'CreateHtmlView(Project_Interfaz.GetContentFile(Project_Path & rowControl("class_code") & ".view"), rowControl("id") & ".cjx", rowControl("iframe"), rowControl("class_code"))
                                Next
                                range.pasteHTML(HtmlDataToPaste)
                            End If
                        End If
                    End If
                    'Dim currentSelection As IHTMLSelectionObject = htmlDocument.activeElement.insertAdjacentHTML("", HtmlDataToPaste)
                Else
                    If Command = "Copy" Then
                        Dim htmlDocument As IHTMLDocument2 = webDesign.Document.DomDocument
                        Dim currentSelection As IHTMLSelectionObject = htmlDocument.selection
                        If Not currentSelection Is Nothing Then
                            Dim range As IHTMLTxtRange = currentSelection.createRange()
                            If Not range Is Nothing Then
                                HtmlDataCopied = range.htmlText
                            End If
                        End If
                    Else
                        Me.HTML.HTML.ExecCommand(Command, False, Value)
                    End If
                End If
            End If
        End If
        If Me.btnHTML.Visible = True Then 'see if enable dezign properties, event a controls
            If Me.btnHTML.Enabled = False Then 'html selected
                If Command = "Undo" Then
                    Me._EditorControlHTML.Undo()
                End If
                If Command = "Redo" Then
                    Me._EditorControlHTML.Redo()
                End If
            End If
        End If
        If Me.btnCode.Visible = True Then 'see if enable dezign properties, event a controls
            If Me.btnCode.Enabled = False Then 'code selected
                If Command = "Undo" Then
                    Me._EditorControlCode.Undo()
                End If
                If Command = "Redo" Then
                    Me._EditorControlCode.Redo()
                End If
            End If
        End If
    End Sub


    ' Demonstrates SetData, ContainsData, and GetData.
    Public Function SwapClipboardFormattedData(ByVal format As String, ByVal data As Object) As Object

        Dim returnObject As Object = Nothing

        If (Clipboard.ContainsData(format)) Then
            returnObject = Clipboard.GetData(format)
            Clipboard.SetData(format, data)
        End If

        Return returnObject

    End Function

    Private Sub TSTags_ItemClicked(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles TSTags.ItemClicked


    End Sub

    Private Sub webDesign_PreviewKeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles webDesign.PreviewKeyDown
        If e.Control And e.KeyCode = 83 Then
            Control_Main.Save()
        End If
    End Sub

    Private Sub SetEdition()
        If TextLoaded Then
            If Not General.Control_Main.tabContainer.ItemTitles.Item(General.Control_Main.ActualEditor).IndexOf("*") > 0 Then
                General.Control_Main.tabContainer.ItemTitles.Item(General.Control_Main.ActualEditor) = General.Control_Main.tabContainer.ItemTitles.Item(General.Control_Main.ActualEditor) & " *"
            End If
        End If
    End Sub

    Private Sub _EditorControlCode_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles _EditorControlCode.TextChanged
        SetEdition()
    End Sub

    Private Sub _EditorControlHTML_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles _EditorControlHTML.TextChanged
        SetEdition()
    End Sub

    Public Function GetBreakPoints() As xdc.XDebug.Breakpoint()
        Return Me._EditorControlCode.GetBreakPoints()
    End Function

    Public Sub SetActiveFileAndLine(ByVal iLine As Long)

        btnDesign.Enabled = True
        btnHTML.Enabled = True
        btnCode.Enabled = False

        Me.PnDesign.Visible = False
        Me.PnHTML.Visible = False
        Me.PnCodeBase.Visible = True

        Me.PnCodeBase.Dock = DockStyle.Fill
        Me.PnCodeBase.Visible = True
        Me.pnCode.Visible = True

        _EditorControlCode.Document(iLine).BackColor = Color.Orange
        _EditorControlCode.Document(iLine).Bookmarked = True
        '_EditorControlCode.ScrollIntoView(iLine - 10)
        _EditorControlCode.GotoLine(iLine - 10)
    End Sub

    Public Sub RemoveActiveMarks()
        For iLine = 0 To _EditorControlCode.Document.Lines.Length - 1
            _EditorControlCode.Document(iLine).BackColor = Color.White
            _EditorControlCode.Document(iLine).Bookmarked = False
        Next
    End Sub

    Public Function ActualSelectionWord() As String
        Return _EditorControlCode.Selection.Text
    End Function
End Class
